<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <title>Forms</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
    <link rel="stylesheet" href="assets/css/ready.css">
    <link rel="stylesheet" href="assets/css/demo.css">
    <script src="bootstrap/js/jquery.min.js"></script>
    <script src="../homePage/layer/layer.js"></script>
    <script src="angularjs/angular.min.js"></script>
</head>
<style type="text/css">
    .main-panel {
        background-color: #FFFFFF !important;
    }

    .content {
        background-color: #FFFFFF !important;
    }
</style>
<script>
    var app = angular.module("myApp", []);
    app.controller("myCtrl", function ($scope, $http) {
        let user = sessionStorage.getItem("user");
        $scope.userid = JSON.parse(user).userid;
        $scope.username = JSON.parse(user).username;
        // $scope.userid = 40;
        $scope.getPolicy = function () {
            $http.get("http://localhost:8002/policy/getPolicy?userid=" + $scope.userid).success(function (data) {
                if (data.code == 0) {
                    $scope.policy = data.data;
                } else if (data.code == 101) {
                    layer.msg("您还没有保单", {icon: 5});
                    $scope.message = "您还没有保单!";
                }
            })
        }
        $scope.openModal = function (policyno, money) {
            $("#myModal").modal("show");
            $scope.year = '';
            $scope.policyno = policyno;
            $scope.money = money;
        }
        $scope.addPolicy = function () {
            if ($scope.year === '') {
                layer.msg("请输入增加年限");
            } else {
                var money1 = Number($scope.year) * Number($scope.money);
                var str = "<div>" +
                    "<h4 align='center'>" +
                    "请支付：" + money1 + " 元</h4>" +
                    "<p><img src='../homePage/img/支付.png' style='width: 250px;height: 180px'/> </p>" +
                    "</div>";
                layer.confirm(str, {
                        btn: ['确定', '取消'] //按钮
                    },
                    function () {
                        $http.get("http://localhost:8002/policy//addPolicy?policyno=" + $scope.policyno + "&year=" + $scope.year).success(function (data) {
                            if (data.code == 0) {
                                $scope.policy = data.data;
                                $scope.getPolicy();
                                layer.msg(data.msg, {icon: 6});
                            } else if (data.code == 404) {
                                $scope.getPolicy();
                                layer.msg(data.msg, {icon: 5});
                            } else if (data.code == -1) {
                                $scope.getPolicy();
                                layer.msg(data.msg, {icon: 5});
                            } else if (data.code == -2) {
                                $scope.getPolicy();
                                layer.msg(data.msg, {icon: 5});
                            }
                        });
                        layer.msg('支付成功');
                        $("#myModal").modal("hide");
                        $scope.policyno = "";
                        $scope.year = "";
                    },
                    function () {
                        layer.msg('支付失败');
                        $("#myModal").modal("hide");
                        $scope.policyno = "";
                        $scope.year = "";
                        $scope.getPolicy();
                    }
                );

            }
            ;
        }
    });

    //退出登陆
    function quiet() {
        sessionStorage.clear();
        window.location.href = "../homePage/index.html";
    }

</script>
<body ng-app="myApp" ng-controller="myCtrl" ng-init="getPolicy()">
<div class="wrapper">
    <div class="main-header">
        <div class="logo-header">
            <a href="index.html" class="logo">
                <img src="../homePage/img/logo.png" style="height: 40px;width: 100px">个人中心
            </a>
            <button class="navbar-toggler sidenav-toggler ml-auto" type="button" data-toggle="collapse"
                    data-target="collapse"
                    aria-controls="sidebar" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="topbar-toggler more"><i class="la la-ellipsis-v"></i></button>
        </div>
        <nav class="navbar navbar-header navbar-expand-lg">
            <div class="container-fluid">
                <a href="../homePage/index.html" style="color: #000000; font-size: 16px;">返回首页</a>

                <ul class="navbar-nav topbar-nav ml-md-auto align-items-center">


                    <li class="nav-item dropdown">当前用户:
                        <a class="dropdown-toggle profile-pic" data-toggle="dropdown" href="#" aria-expanded="false">
                            <span>{{username}}</span>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <div class="user-box">

                                    <div class="u-text">
                                        <p class="text-muted">hello@themekita.com</p>
                                        <a onclick="quiet()" class="btn btn-rounded btn-danger btn-sm">退出登录</a>
                                    </div>
                                </div>
                            </li>

                        </ul>
                        <!-- /.dropdown-user -->
                    </li>
                </ul>
            </div>
        </nav>
    </div>
    <div class="sidebar">
        <div class="scrollbar-inner sidebar-wrapper">
            <div class="user">
                <div class="info">
                    <a class="" data-toggle="collapse" href="#collapseExample" aria-expanded="true">

								<span>

									<span class="user-level">修改信息</span>
                                    <!-- <span class="badge badge-count">未实名</span> -->
									<span class="caret"></span>
								</span>
                    </a>
                    <div class="clearfix"></div>

                    <div class="collapse in" id="collapseExample" aria-expanded="true" style="">
                        <ul class="nav">

                            <li>
                                <a href="password.html">
                                    <span class="link-collapse">修改密码</span>
                                </a>
                            </li>
                            <li>
                                <a href="authentication.html">
                                    <span class="link-collapse">实名认证</span>
                                </a>
                            </li>
                            <li>
                                <a href="update.html">
                                    <span class="link-collapse">编辑资料</span>
                                </a>
                            </li>
                            <li>
                                <a href="gobindcar.html">
                                    <span class="link-collapse">绑定车辆</span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <ul class="nav">
                <li class="nav-item">
                    <a href="home.html">
                        <i class="la la-fonticons"></i>
                        <p>首页管理</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="myOrder.html">
                        <i class="la la-dashboard"></i>
                        <p>我的订单</p>
                        <!-- <span class="badge badge-count">5</span> -->
                    </a>
                </li>
                <li class="nav-item active">
                    <a href="guarantee.html">
                        <i class="la la-table"></i>
                        <p>我的保单</p>
                        <!-- <span class="badge badge-count">14</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="claim.html">
                        <i class="la la-keyboard-o"></i>
                        <p>我的理赔</p>
                        <!-- <span class="badge badge-count">50</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="bindcar.html">
                        <i class="la la-th"></i>
                        <p>我的车辆</p>
                        <!-- <span class="badge badge-count">6</span> -->
                    </a>
                </li>
                <li class="nav-item">
                    <a href="applyclaim.html">
                        <i class="la la-th"></i>
                        <p>申请理赔</p>
                        <!-- <span class="badge badge-count">6</span> -->
                    </a>
                </li>
            </ul>
        </div>
    </div>
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <h4 class="page-title">我的保单</h4>
                <div class="row">
                    <div class="col-md-12">
                        <p style="text-align: center;color: #8c8c8c;font-size: 25px">{{message}}</p>
                        <div class="card" ng-repeat="p in policy">

                            <div class="card-header">
                                <h4 class="card-title" ng-repeat="t in p.tSafetypeitem">车险名:&nbsp;&nbsp;&nbsp;{{t.description}}</h4>
                                <p class="card-category">保单号:({{p.policyno}})&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    创建时间:({{p.createtime | date:"yyyy-MM-dd HH:mm:ss"}})</p>
                            </div>
                            <div class="card-body">
                                <br class="card-category">被保人姓名:&nbsp;&nbsp;&nbsp;{{p.insuredpersonname}}&nbsp;&nbsp;&nbsp;
                                    &nbsp;&nbsp;</br>
                                    保险状态:&nbsp;&nbsp;&nbsp;
                                    <d ng-if="p.safestate==0">已过期</d>
                                    <d ng-if="p.safestate==1">正在生效</d>
                                    </br>
                                    生效时间&nbsp;&nbsp;&nbsp;{{p.effecttime|date:"yyyy-MM-dd HH:mm:ss"}}
                                    &nbsp;&nbsp;&nbsp;到期时间&nbsp;&nbsp;&nbsp;{{p.expiretime|date:"yyyy-MM-dd HH:mm:ss"}}
                                </p>
                                <!--<p ng-repeat="o in p.tOrder"> 车&nbsp;&nbsp;&nbsp;&nbsp;主:&nbsp;&nbsp;&nbsp;{{o.carmastername}}&nbsp;&nbsp;&nbsp;
                                    </br>车型号:&nbsp;&nbsp;&nbsp;{{o.cartype}}&nbsp;&nbsp;&nbsp;
                                    </br>车牌号:&nbsp;&nbsp;&nbsp;{{o.carnumber}}&nbsp;&nbsp;&nbsp;
                                </p>-->
                                <div class="text-left">
                                    <button class="btn btn-success" ng-click="openModal(p.policyno,p.money)">加保</button>
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <!--模态框-->
        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
             style="margin-top: 150px">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">

                        <h4 class="modal-title" id="myModalLabel">加保</h4>
                    </div>

                    <div class="modal-body ">
                        <input type="hidden" ng-model="policyno"/>
                        <input  type="hidden" ng-model="money"/>
                        增加时间 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                        <input class="col-sm-4" ng-model="year"/> &nbsp;年
                    </div>

                    <div class="modal-footer">
                        <button type="button" class="btn btn-info" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-info" ng-click="addPolicy()">确认加保</button>
                    </div>
                </div>
            </div>
        </div>

        <footer class="footer">
            <div class="container-fluid">
                <nav class="pull-left">
                    <ul class="nav">
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                ThemeKita
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">
                                Help
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#license/#free-item">
                                Licenses
                            </a>
                        </li>
                    </ul>
                </nav>
                <div class="copyright ml-auto">
                    Copyright &copy; 2020 无忧车险责任有限公司
                </div>
            </div>
        </footer>
    </div>
</div>

</body>
<script src="assets/js/core/jquery.3.2.1.min.js"></script>
<script src="assets/js/plugin/jquery-ui-1.12.1.custom/jquery-ui.min.js"></script>
<script src="assets/js/core/popper.min.js"></script>
<script src="assets/js/core/bootstrap.min.js"></script>
<script src="assets/js/plugin/chartist/chartist.min.js"></script>
<script src="assets/js/plugin/chartist/plugin/chartist-plugin-tooltip.min.js"></script>
<script src="assets/js/plugin/bootstrap-notify/bootstrap-notify.min.js"></script>
<script src="assets/js/plugin/bootstrap-toggle/bootstrap-toggle.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/jquery.mapael.min.js"></script>
<script src="assets/js/plugin/jquery-mapael/maps/world_countries.min.js"></script>
<script src="assets/js/plugin/chart-circle/circles.min.js"></script>
<script src="assets/js/plugin/jquery-scrollbar/jquery.scrollbar.min.js"></script>
<script src="assets/js/ready.min.js"></script>
</html>